Skip to main content

All Questions

0votes
2answers
601views

How to solve an issue when a decorator needs variables from the base class?

I have a service class that does some magic. I want to introduce a new type of functionality - raise an event. I am absolutely sure that decorator pattern is great for this scenario. The problem is ...
pro100tom's user avatar
5votes
4answers
14kviews

Why the industry prefer/use composition over inheritance? [duplicate]

I was having a discussion with few friends about inheritance and composition and what I learnt from that discussion is that the use of inheritance more or less condemned in industry nowadays and ...
Diaufh138's user avatar
4votes
4answers
3kviews

Composition over Inheritance, why not both?

I have this out of context scenario, where what I think is good practices leaves me in a situation of both implementing an interface, and using composition to do the implementation. Imagine the ...
Chris Wohlert's user avatar
3votes
3answers
162views

Base Class vs Common Member Class

Imagine I have two classes like this... public class SingleplayerGameSetup { public int Seed { get; private set; } public int AiNations { get; private set; } } public class ...
starikcetin's user avatar
6votes
2answers
4kviews

How to replace inheritance with composition in this case?

I've recently read several articles about the advantages of the composition over inheritance. Their authors said that you can always replace inheritance with composition (to be precise, they say they ...
user avatar
1vote
2answers
486views

Inheritance vs 'specification' by fields

I'm currently reading 'Head first design patterns' and I already have a few questions on the first chapter of the book. This chapter introduces the 'prefer composition over inheritance' design ...
user avatar
1vote
2answers
402views

Alternatives to inheritance on complex structures?

I'm working on an ASP.NET Webforms project, using the MVP Pattern (which the presenters as you may know use a Page Controller pattern). I'm given a rather complex inheritance chain for my controllers. ...
David Jiménez Martínez's user avatar
9votes
3answers
5kviews

Why should one subclass instead of composite when using the Factory Method design pattern?

I'm currently learning about design patterns. I learned about the Factory Method pattern. This pattern means that in order to implement a factory to create objects, one should subclass the class that ...
Aviv Cohn's user avatar
0votes
2answers
357views

Inheritance versus Composition in a business application

I have a training management and tracking system, with a high level structure as follows: We have a Role1, e.g. Manager, Shift-boss, miner, etc. and a Candidate, training for that Role. The role has ...
ProfK's user avatar

close